package cn.xenosp.server.module.role.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.xenosp.server.common.tools.IdUtil;
import cn.xenosp.server.common.tools.ObjectConvert;
import cn.xenosp.server.module.role.entity.SysRole;
import cn.xenosp.server.module.role.entity.SysRoleVO;
import cn.xenosp.server.module.role.mapper.SysRoleMapper;
import cn.xenosp.server.module.role.service.SysRoleService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
* @author TongHui
* @description 针对表【sys_role(角色信息表)】的数据库操作Service实现
* @createDate 2024-10-20 19:57:18
*/
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole>
    implements SysRoleService{

    @Override
    public IPage getPage(SysRoleVO sysRoleVO) {
        SysRole sysRole = new SysRole();
        Page page = new Page(sysRoleVO.getPage(), sysRoleVO.getLimit());
        ObjectConvert.copyVoToEntity(sysRoleVO,sysRole);
        return baseMapper.page(page,sysRole);
    }

    @Override
    public void save(SysRoleVO sysRoleVO) {
        SysRole sysRole = new SysRole();
        ObjectConvert.copyVoToEntity(sysRoleVO,sysRole);
        sysRole.setId(IdUtil.getId());
        save(sysRole);
    }

    @Override
    public void update(SysRoleVO sysRoleVO) {
        SysRole sysRole = new SysRole();
        ObjectConvert.copyVoToEntity(sysRoleVO,sysRole);
        updateById(sysRole);
    }

    @Override
    public void delete(SysRoleVO sysRoleVO) {
        SysRole sysRole = new SysRole();
        ObjectConvert.copyVoToEntity(sysRoleVO,sysRole);
        removeById(sysRole);
    }
}




